package sbc.ejb3.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

public interface IGenericDAO<T, ID extends Serializable> {
    
    /**
     * Gets an entity by it's id.
     * @param id the entity's id.
     * @return the found entity or null if it's not present.
     */
    T getById(ID id);
    
    /**
     * Gets all entities of the specific type.
     * Returns max entities, beginning at the specified row,
     * if they are not null.
     * @return all found entities.
     */
    List<T> getAll(Integer max, Integer first);
    
    List<T> getAll();
        
    /**
     * Persists the entity.
     * @param entity the entity to persist.
     */
    void persist(T entity);
    
    /**
     * Persists all entities of the collection.
     * @param entities the entities to persist.
     */
    void persistAll(Collection<T> entities);    
    
    /**
     * Persists all entities of the sequence.
     * @param entities the entities to persist.
     */
    void persistAll(T... entities);
    
    /**
     * Removes the entity from the persistent storage.
     * @param entity the entity to remove.
     */
    void remove(T entity);
    
    /**
     * Removes all entities of the collection from the persistent storage.
     * @param entities the entities to remove.
     */
    void removeAll(Collection<T> entities);
    
    /**
     * Removes all entities of the sequence from the persistent storage.
     * @param entities the entities to persist.
     */
    void removeAll(T... entities);
    
    /**
     * Merges the entity.
     * @param entity the entity to merge.
     * @return the merged entity
     */
    T merge(T entity);
    
}
